Pheet meets C++11

نویسنده

  • Manuel Pöter
چکیده

Pheet is a C++ task-scheduling framework that allows for easy customization of internal data-structures. The implementation was started before the C++11 standard was committed and therefore did not use the new standardized memory model but compiler/platform specific intrinsics for atomic memory operations. This not only makes the implementation harder to port to other compilers or architectures but also suffers from the fact that prior C++ versions did not specify any memory model. In this report I discuss the porting of one of the internal Pheet data structures to the new memory model and provide reasoning about the correctness based on the semantics of the memory consistency model. Using two benchmarks from the Pheet benchmark suite I compare the performance of the original against the new implementation which shows a significant speedup under certain conditions on one of the two test machines. Introduction Pheet, developed by Wimmer [10], is a highly customizable task scheduling framework developed in C++ that allows comparison between different implementations of data structures used in the scheduler, as well as comparisons between entirely different schedulers. The customization options are based on the powerful template meta-programming possibilities provided by the C++ language. Even though the framework is fully customizable and allows replacing almost all of the internal data structures, the template meta-programming approach produces high-performance code since C++ templates are instantiated at compile time and therefore all the usual compiler optimizations like inline expansion, dead-code elimination, etc. can by applied. It is easy to use and provides good performance. Although the framework makes extensive use of many new language features that were introduced in C++11 (mainly template aliases and variadic templates) the development started before the C++11 standard was officially adopted by the standards committee. ∗This report was the outcome of a project from autumn 2013 to summer 2014 at the Parallel Computing group at the Vienna University of Technology. The project was supervised by Martin Wimmer and Jesper Larsson Träff, and also resulted in [12]. http://www.pheet.org 1 ar X iv :1 41 1. 19 51 v1 [ cs .D C ] 7 N ov 2 01 4 For this reason the original implementation did not use the new memory model that was introduced with C++11, but instead relied on macros that resolved to compiler/platform specific intrinsics. The C++ Standard prior to C++11 specified program execution in terms of observable behavior, which in turn described sequential execution on an implicitly singlethreaded abstract machine. Therefore multi-threaded C++ programs relied on set of libraries for threading support like POSIX threads, Win32, or Boost. Unfortunately a pure library approach, in which the compiler is designed independently of threading issues, includes all sorts of problems [4]. Without a clearly defined memory model as a common ground between the compiler, the hardware, the threading library, and the programmer, multi-threaded C++ code is fundamentally at odds with compiler and processor-level optimizations [8]. In August 2011 the ISO C++ committee finally approved the next C++ standard – commonly referred to as C++11. This new standard defines a multi-threaded abstract machine, together with a well-defined memory model and library support for interaction between threads. The memory model defines when multiple threads may access the same memory location, and specifies when updates by one thread become visible to other threads. This not only allows development of multi-threaded applications in a platform independent and portable way, but also to formally prove the correctness based on the memory order semantics. Unfortunately at the beginning of the development of Pheet the C++11 standard was not finalized and no implementation of the proposed memory model was available in gcc. For this reason none of the early data structures were developed using the new memory model, but instead with a few macros that resolve to compiler specific intrinsics for atomic operations like fetch-and-add or compare-and-swap. My task was to provide an adapted implementation of the CentralKStrategy data structures based on the new memory model instead of the old macros and to provide a reasoning about the correctness of the new implementation based on the memory order semantics. The following description of the implementation and the code listings are based on revision 573 from https://launchpad.net/pheet. The C++11 memory model The new memory model of C++11 is largely based on the work by Boehm, Alexandrescu et al [5, 3]. One of the most important aspects is the definition of a data race [6, p. 14]: The execution of a program contains a data race if it contains two conflicting actions in different threads, at least one of which is not atomic, and neither happens before the other. Any such data race results in undefined behavior. Where conflicting actions are defined as follows [6, p. 11]: Since the official C++ standard is not freely available I will instead refer to the ”Working Draft, Standard for Programming Language C++“ from January 2012 [6] which contains the C++11 standard plus minor editorial changes.

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Policy Capacity Meets Politics; Comment on “Health Reform Requires Policy Capacity”

It is difficult to disagree with the general argument that successful health reform requires a significant degree of policy capacity or that all players in the policy game need to move beyond self-interested advocacy. However, an overly broad definition of policy capacity is a problem. More important perhaps, health reform inevitably requires not just policy capacity but political leadership an...

متن کامل

Modular Correspondences on X ( 11 ) by Allan Adler

In this paper, we show how to give a geometric interpretation of the modular correspondence T3 on the modular curve X(11) of level 11 using projective geometry. We use Klein’s theorem that X(11) is isomorphic to the nodal curve of the Hessian of the cubic threefold Λ defined by V W +W X + XY + Y Z + ZV = 0 in P(C) and geometry which we learned from a paper of W.L.Edge. We show that the correspo...

متن کامل

One-dimensional Schrödinger Operators with Slowly Decaying Potentials: Spectra and Asymptotics or Baby Fourier Analysis Meets Toy Quantum Mechanics

1. Pre-Introduction 2 2. Introduction and background 2 3. Three (sample) principal results 5 4. A criterion for ac spectrum 6 5. Expansions for generalized eigenfunctions 9 6. WKB approximation 10 7. Transmission and reflection coefficients 11 8. Reduction and expansion 13 9. Maximal operators 14 10. Multilinear operators and maximal variants 18 11. Wave operators and time-dependent scattering ...

متن کامل

Martin Schürmann , Katrin Amunts and Riitta Hari

[PDF] [Full Text] [Abstract] , September 1, 2005; 94 (3): 2251-2254. J Neurophysiol S. Fecteau, J. L. Armony, Y. Joanette and P. Belin Sensitivity to Voice in Human Prefrontal Cortex [PDF] [Full Text] [Abstract] , December 11, 2006; 0 (2006): bhl141v1-12. Cereb Cortex R. M. Willems, A. Ozyurek and P. Hagoort When Language Meets Action: The Neural Integration of Gesture and Speech [PDF] [Fu...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:
  • CoRR

دوره abs/1411.1951  شماره 

صفحات  -

تاریخ انتشار 2014